const basUrl = "https://api-hmugo-web.itheima.net/api/public/v1/"

function http(url, methods = 'GET', data = {}) {
  return new Promise(function (resolve, reject) {
    wx.showLoading({
      title: "加载中",
      mask: true
    });
    wx.request({
      url: basUrl + url,
      methods: methods,
      data: data,
      // 成功的回调函数
      success: function (res) {
        resolve(res)
      },
      // 失败的回调函数
      fail: function (res) {
        reject(res)

      },
      complete: () => {
        //  关闭正在等待的图标
        wx.hideLoading();
      }

    })

  })

}


export default http